package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbPoolPackage;
import com.ruoyi.system.service.ITbPoolPackageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 池套餐管理Controller
 * 
 * @author ruoyi
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/poolPackage")
public class TbPoolPackageController extends BaseController
{
    @Autowired
    private ITbPoolPackageService tbPoolPackageService;

    /**
     * 查询池套餐管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:poolPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbPoolPackage tbPoolPackage)
    {
        startPage();
        List<TbPoolPackage> list = tbPoolPackageService.selectTbPoolPackageList(tbPoolPackage);
        return getDataTable(list);
    }

    /**
     * 导出池套餐管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:poolPackage:export')")
    @Log(title = "池套餐管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPoolPackage tbPoolPackage)
    {
        List<TbPoolPackage> list = tbPoolPackageService.selectTbPoolPackageList(tbPoolPackage);
        ExcelUtil<TbPoolPackage> util = new ExcelUtil<TbPoolPackage>(TbPoolPackage.class);
        util.exportExcel(response, list, "池套餐管理数据");
    }

    /**
     * 获取池套餐管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:poolPackage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbPoolPackageService.selectTbPoolPackageById(id));
    }

    /**
     * 新增池套餐管理
     */
    @PreAuthorize("@ss.hasPermi('system:poolPackage:add')")
    @Log(title = "池套餐管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPoolPackage tbPoolPackage)
    {
        return toAjax(tbPoolPackageService.insertTbPoolPackage(tbPoolPackage));
    }

    /**
     * 修改池套餐管理
     */
    @PreAuthorize("@ss.hasPermi('system:poolPackage:edit')")
    @Log(title = "池套餐管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPoolPackage tbPoolPackage)
    {
        return toAjax(tbPoolPackageService.updateTbPoolPackage(tbPoolPackage));
    }

    /**
     * 删除池套餐管理
     */
    @PreAuthorize("@ss.hasPermi('system:poolPackage:remove')")
    @Log(title = "池套餐管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbPoolPackageService.deleteTbPoolPackageByIds(ids));
    }
}
